package com.dfrz.problem.action.staffmanage;

import org.apache.struts2.dispatcher.SessionMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dfrz.problem.model.Employee;
import com.dfrz.problem.model.User;
import com.dfrz.problem.service.DeleteEmployeeService;
import com.dfrz.problem.utils.IConstant;
import com.dfrz.problem.utils.Result;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class DeleteEmployeeAction extends ActionSupport{
	
	private static final long serialVersionUID = 1L;
	private static final Logger logger = LoggerFactory.getLogger(DeleteEmployeeAction.class);
	
	private DeleteEmployeeService deleteEmployeeService;
	private User user;
	private Employee employee;
	
	/**
	 * 删除用户信息校验
	 */
	public String deleteEmployee(){
		Result<Employee> result = deleteEmployeeService.deleteEmployee(employee.getEmployeeEmail());
		if (IConstant.DELETE_EMPLOYEE_ERROR.equals(result.getCode())) {
			addFieldError("eamilErro", getText(IConstant.DELETE_EMPLOYEE_ERROR));
			return INPUT;
		}
		
		return SUCCESS;
	}
	
	public String deleteInterface(){
		return SUCCESS;
	}

	public void setDeleteEmployeeService(DeleteEmployeeService deleteEmployeeService) {
		this.deleteEmployeeService = deleteEmployeeService;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public static Logger getLogger() {
		return logger;
	}

	public DeleteEmployeeService getDeleteEmployeeService() {
		return deleteEmployeeService;
	}
	
	public void setUser(User user) {
		this.user = user;
	}
	
	public User getUser() {
		SessionMap<String, Object> session = (SessionMap<String, Object>)
				ActionContext.getContext().getSession();
		user = (User) session.get("user");
		return user;
	}

}
